/*
 * Copyright 2009 Vladimir Ritz Bossicard
 *
 * This file is part of OraDoc.
 *
 * OraDoc is free software: you can redistribute it and/or modify it under the
 * terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later
 * version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program. If not, see <http://www.gnu.org/licenses/>.
 *
 * Version     : $Revision: 23 $
 * Last edit   : $Date: 2009-05-29 11:58:29 +0000 (Fri, 29 May 2009) $
 * Last editor : $Author: vbossica $
 */
package org.oradoc.config;

import java.io.File;

import org.oradoc.projects.Project;
import org.oradoc.projects.outputters.ProjectHtmlOutputter;
import org.oradoc.projects.outputters.ProjectOutputter;
import org.springframework.config.java.annotation.Bean;
import org.springframework.config.java.annotation.ExternalValue;
import org.springframework.config.java.annotation.valuesource.SystemPropertiesValueSource;

import freemarker.template.DefaultObjectWrapper;

/**
 *
 * @author Vladimir Ritz Bossicard
 */
@SystemPropertiesValueSource
public abstract class AbstractConfiguration implements Configuration {

    @ExternalValue("project.name")
    private String name;
    @ExternalValue("project.version")
    private String version;

    @ExternalValue("outdir")
    private String out;

    @Bean
    public Project project() {
        return new Project(this.name, this.version);
    }

    @Bean
    public ProjectOutputter outputter() {
        ProjectHtmlOutputter outputter = new ProjectHtmlOutputter();

        outputter.setConfiguration(FreemarkerUtils.createClassloaderConfiguration(getClass()));
        outputter.setOutputDir(new File(this.out));

        return outputter;
    }

}
